package shapewar.view.myview;

import shapewar.engine.presenter.EngineThread;

public class InvalidateThread {
	public static EngineThread et;
	public static MyView myviews[] = new MyView[500];
	public static int i_view = 0,j_view = 0;
	public static int max_i = 0;
	
	public void start() {
		if(et==null){
			et = new EngineThread(32){
				@Override
				public void repeat() {
					doinvalidate();
				}
			};
			et.start();
		}
	}
	
	public void add(MyView view){
		myviews[i_view++%myviews.length] = view;
	}
	
	int max = 0;
	public void doinvalidate() {
		if(j_view<i_view){
			if(max<(i_view-j_view)){
				max = i_view-j_view;
			}
		}
		while(j_view<i_view){
			myviews[j_view++%myviews.length].doinvalidate();
		}
	}
	
}
